package Chapter2.Comparing.c8;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

public class FileReader1Demo {
    public static void main(String[] args) {
        try {
            RandomAccessFile raf = new RandomAccessFile("Doc/a.txt","rw");
            long prePos = raf.getFilePointer();
            int a = raf.read();
            int key=12321;
            while (a!=-1) {
                raf.seek(prePos);
                raf.write(a^key);
                prePos = raf.getFilePointer();
                a=raf.read();
            }
            raf.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
